package com.demo.persistencia.generica.modelo;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import sun.org.mozilla.javascript.internal.regexp.SubString;


public class TOTO {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
	String ruta = TOTO.class.getClassLoader().getResource("com/demo/persistencia/generica/modelo").getFile();
		TOTO clase = new TOTO();
		String rutajava = ruta.replaceFirst("build/classes", "src");
		System.out.println(rutajava);
		  File file = new File(rutajava);
		  if(file.exists()){
		   File[] daos = file.listFiles();
		   List<String> lstString = new ArrayList<String>();
		   for (int i = 0; i < daos.length; i++) {
			if(clase.verificar(daos[i])!=""){
			   lstString.add(clase.verificar(daos[i]));
			}
			   
		}
		
		   for (String file2 : lstString) {
				System.out.println("ss : "+ file2);
			}
		  }

	}
	
	
	public String verificar(File file){
		BufferedReader bReader;
		String sretorno="";
		   try {
				bReader = new BufferedReader(new FileReader(file));
				
				String linea = bReader.readLine();
			    while (linea != null) {
			    	
			    	linea = bReader.readLine();
			    	if(linea!=null&&linea.startsWith("@Searchable")){
			    		 sretorno= file.getName().trim().substring(0,file.getName().trim().lastIndexOf('.'));
			    	    break;
			    	}
				    }
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}   		  
		   return sretorno;
	}
	

}
